﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Utilities;

namespace Models
{
    public class StockChangeRecordView : ViewBase
    {
        [Display(Name = "库存品种变化类型"), Required(ErrorMessage = "请选择库存品种变化类型")]
        public int? StockChangeTypeID { get; set; }
        public virtual StockChangeType StockChangeType { get; set; }

        [Display(Name = "库存变化名称"), Required(ErrorMessage = "请选择库存变化类型名称")]
        public string StockChangeName { get; set; }

        [Display(Name = "品质")]
        public string QualityName{ get; set; }

        [Display(Name = "分类")]
        public string CategoryName{ get; set; }

        [Display(Name = "所在单位"), Required(ErrorMessage = "请选择库存变化所在单位")]
        public string AreaName { get; set; }

        [Display(Name = "所在仓库"), Required(ErrorMessage = "请选择库存变化所在仓库")]
        public string WarehouseName  { get; set; }

        [Display(Name = "容量(吨)"), Required(ErrorMessage = "请输入库存变化容量"), Range(0, Double.MaxValue)]
        public double Volume { get; set; }

        public StockChangeRecordView(StockChangeRecord s)
        { 
            StockChangeType = s.StockChangeType;
            StockChangeName = s.StockChangeName;
            WarehouseName = s.Warehouse.WarehouseName;
            AreaName = s.Area.AreaName;
            Volume = s.Volume;
            ID = s.ID;
            CategoryName = s.Category.CategoryName;
            QualityName = s.Quality.QualityName;
            Description = s.Description;
            Sequence = s.Sequence;
        }
    }

    public class StockChangeRecord:EntityBase
    {
        [Display(Name = "库存品种变化类型"), Required(ErrorMessage = "请选择库存品种变化类型")]
        public int? StockChangeTypeID { get; set; }
        public virtual StockChangeType StockChangeType { get; set; }

        [Display(Name = "库存变化类型名称"), Required(ErrorMessage = "请选择库存变化类型名称")]
        public string StockChangeName { get; set; }

        [Display(Name = "品质"), Required(ErrorMessage = "请选择库存变化品质")]
        public int? QualityID { get; set; }
        public virtual Quality Quality { get; set; }

        [Display(Name = "分类"), Required(ErrorMessage = "请选择库存变化分类")]
        public int? CategoryID { get; set; }
        public virtual Category Category { get; set; }

        [Display(Name = "所在单位"), Required(ErrorMessage = "请选择库存变化所在单位")]
        public int? AreaID { get; set; }
        public virtual Area Area { get; set; }

        [Display(Name = "所在仓库"), Required(ErrorMessage = "请选择库存变化所在仓库")]
        public int? WarehouseID { get; set; }
        public virtual Warehouse Warehouse { get; set; }

        [Display(Name = "容量(吨)"),  Range(0,Double.MaxValue)]
        public double Volume { get; set; }
    }
}